1438B - Valerii Against Everyone - CodeForces Solution


constructive algorithms data structures greedy sortings *1000

Please click on ads to support us..

Python Code:

import sys


l = sys.stdin.readlines()
i = 0

t = int(l[i].replace('\n',''))
i=1
while True:
    n = int(l[i].replace('\n',''))
    i+=1
    b = [int(x) for x in l[i].replace('\n', '').split()]
    i+=1

    b.sort()
    aux = 1
    for j in range(1,len(b)):
        aux = b[j] - b[j-1]
        if aux == 0:
            print('YES')
            break
    if aux != 0:
        print('NO')
    if i == len(l):
        break
		   	    		 	 			 		 	  	   	

C++ Code:

#include <bits/stdc++.h>
using namespace std;

#define FAST()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define wTC()                         \
    int t;                            \
    cin >> t;                         \
    for (int i = 1; i <= t; i++)      \
    {                                 \
        cout << "Case " << i << ": "; \
        nasim();                      \
    }
#define TC()     \
    int t;       \
    cin >> t;    \
    while (t--)  \
    {            \
        nasim(); \
    }
#define nTC()    \
    int t = 1;   \
    while (t--)  \
    {            \
        nasim(); \
    }

#define endl "\n"
#define ll long long int
#define mod 1e9 + 7
#define all(x) x.begin(), x.end()
#define getunique(v)                                  \
    {                                                 \
        sort(v.begin(), v.end());                     \
        v.erase(unique(v.begin(), v.end()), v.end()); \
    }

void nasim()
{
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++)
    {
       int a;
       cin>>a;
       s.insert(a);
    }
    if(s.size()==n)
    {
        cout<< "NO"<<endl;
    }
    else
    {
        cout<< "YES"<<endl;
    }
}

int main()
{
    FAST()
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    // nTC();

    TC();

    // wTC();
}


Comments

Submit
0 Comments
More Questions

49A - Sleuth
1541A - Pretty Permutations
1632C - Strange Test
673A - Bear and Game
276A - Lunch Rush
1205A - Almost Equal
1020B - Badge
1353A - Most Unstable Array
770A - New Password
1646B - Quality vs Quantity
80A - Panoramix's Prediction
1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera
776A - A Serial Killer
25B - Phone numbers
1633C - Kill the Monster
1611A - Make Even
1030B - Vasya and Cornfield
1631A - Min Max Swap